library(car)
library(sandwich)
library(lmtest)

dta <- read.csv("caschool_dta.csv")

#############
## Table 1 ##
#############

summary(tab1 <- lm(VOTE_SHARE ~ HIGH_EDU + MEDIUM_EDU + LOW_EDU + BIZ + ATTORNEY +
+ LATINO + FEMALE + CAND_SEAT_RATIO + INCUMBENT_NONDESIG + as.factor(YEAR), data = dta))

tab1_cluster <- vcovHC(tab1, type = "HC0", cluster = "RACE_ID", adjust = T)
coeftest(tab1, vcov = tab1_cluster)

##############
## Table A1 ##
##############

summary(taba1 <- lm(VOTE_SHARE ~ HIGH_EDU + MEDIUM_EDU + LOW_EDU + BIZ + ATTORNEY +
            + LATINO + FEMALE + CAND_SEAT_RATIO + INCUMBENT_NONDESIG + as.factor(YEAR), data = dta
            , subset = NUM_CANDS > 1))

## With Clustered SEs
taba1_cluster <- vcovHC(taba1, type = "HC0", cluster = "RACE_ID", adjust = T)
coeftest(taba1, vcov = taba1_cluster)
